<%@tag description="Displays a layer from a WMS as a JSON object" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.atg.com/taglibs/json" prefix="json"%>
<%@taglib uri="/WEB-INF/taglib/wms2kml" prefix="wms2kml"%>
<%@attribute
    name="layer"
    type="uk.ac.rdg.resc.wms2kml.Layer"
    required="true"
    description="Layer object for display as JSON"%>
<json:object>
    <json:property name="label" value="${layer.title}"/>
    <c:if test="${not empty layer.name}">
        <json:property name="id" value="${layer.name}"/>
        <%-- This property is the total number of overlays that this layer
             contains (taking into account all combinations of t and z) --%>
        <json:property name="numOverlays" value="${layer.numOverlays}"/>
    </c:if>
    <c:if test="${not empty layer.children}">
        <json:array name="children" items="${layer.children}" var="child">
            <wms2kml:jsLayer layer="${child}"/>
        </json:array>
    </c:if>
</json:object>